#include "hek1016.h"
#include "user_define.h"
#include "main.h"
#include "lib.h"

#define HEK1016_TX_ID_F01 0x204
#define HEK1016_TX_ID_F02 0x205
#define HEK1016_TX_ID_F03 0x206
#define HEK1016_TX_ID_F04 0x207

#define HEK1016_TX_ID_S01 0x304
#define HEK1016_TX_ID_S02 0x305
#define HEK1016_TX_ID_S03 0x306
#define HEK1016_TX_ID_S04 0x307

#define HEK1016_MODULE_NUMBER 4

uint32_t ul_hek1016_rx_id[HEK1016_MODULE_NUMBER] = {HEK1016_RX_ID_01, HEK1016_RX_ID_02, HEK1016_RX_ID_03, HEK1016_RX_ID_04};
uint32_t ul_hek1016_tx_id_first[HEK1016_MODULE_NUMBER]  = {HEK1016_TX_ID_F01, HEK1016_TX_ID_F02, HEK1016_TX_ID_F03, HEK1016_TX_ID_F04};
uint32_t ul_hek1016_tx_id_second[HEK1016_MODULE_NUMBER] = {HEK1016_TX_ID_S01, HEK1016_TX_ID_S02, HEK1016_TX_ID_S03, HEK1016_TX_ID_S04};

uint8_t uc_hek1016_backlight[HEK1016_MODULE_NUMBER] = { 1,1,1,1 };
uint8_t uc_hek1016_key01[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key02[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key03[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key04[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key05[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key06[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key07[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key08[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key09[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key10[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key11[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key12[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key13[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key14[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key15[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key16[HEK1016_MODULE_NUMBER] = { 0 };

uint8_t uc_hek1016_key01_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key02_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key03_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key04_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key05_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key06_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key07_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key08_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key09_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key10_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key11_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key12_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key13_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key14_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key15_last[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key16_last[HEK1016_MODULE_NUMBER] = { 0 };

uint8_t uc_hek1016_key01_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key02_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key03_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key04_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key05_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key06_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key07_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key08_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key09_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key10_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key11_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key12_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key13_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key14_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key15_cmd[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key16_cmd[HEK1016_MODULE_NUMBER]   = { 0 };

uint8_t uc_hek1016_key01_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key01_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key01_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key02_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key02_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key02_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key03_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key03_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key03_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key04_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key04_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key04_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key05_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key05_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key05_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key06_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key06_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key06_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key07_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key07_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key07_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key08_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key08_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key08_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key09_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key09_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key09_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key10_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key10_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key10_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key11_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key11_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key11_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key12_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key12_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key12_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key13_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key13_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key13_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key14_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key14_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key14_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key15_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key15_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key15_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };
uint8_t uc_hek1016_key16_led_red[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_hek1016_key16_led_green[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_hek1016_key16_led_blue[HEK1016_MODULE_NUMBER]  = { 0 };

void hek1016_led_clear(uint8_t mod)
{
    if(mod >= HEK1016_MODULE_NUMBER) return;
    uc_hek1016_key01_led_red[mod]   = 0;
    uc_hek1016_key01_led_green[mod] = 0;
    uc_hek1016_key01_led_blue[mod]  = 0;
    uc_hek1016_key02_led_red[mod]   = 0;
    uc_hek1016_key02_led_green[mod] = 0;
    uc_hek1016_key02_led_blue[mod]  = 0;
    uc_hek1016_key03_led_red[mod]   = 0;
    uc_hek1016_key03_led_green[mod] = 0;
    uc_hek1016_key03_led_blue[mod]  = 0;
    uc_hek1016_key04_led_red[mod]   = 0;
    uc_hek1016_key04_led_green[mod] = 0;
    uc_hek1016_key04_led_blue[mod]  = 0;
    uc_hek1016_key05_led_red[mod]   = 0;
    uc_hek1016_key05_led_green[mod] = 0;
    uc_hek1016_key05_led_blue[mod]  = 0;
    uc_hek1016_key06_led_red[mod]   = 0;
    uc_hek1016_key06_led_green[mod] = 0;
    uc_hek1016_key06_led_blue[mod]  = 0;
    uc_hek1016_key07_led_red[mod]   = 0;
    uc_hek1016_key07_led_green[mod] = 0;
    uc_hek1016_key07_led_blue[mod]  = 0;
    uc_hek1016_key08_led_red[mod]   = 0;
    uc_hek1016_key08_led_green[mod] = 0;
    uc_hek1016_key08_led_blue[mod]  = 0;
    uc_hek1016_key09_led_red[mod]   = 0;
    uc_hek1016_key09_led_green[mod] = 0;
    uc_hek1016_key09_led_blue[mod]  = 0;
    uc_hek1016_key10_led_red[mod]   = 0;
    uc_hek1016_key10_led_green[mod] = 0;
    uc_hek1016_key10_led_blue[mod]  = 0;
    uc_hek1016_key11_led_red[mod]   = 0;
    uc_hek1016_key11_led_green[mod] = 0;
    uc_hek1016_key11_led_blue[mod]  = 0;
    uc_hek1016_key12_led_red[mod]   = 0;
    uc_hek1016_key12_led_green[mod] = 0;
    uc_hek1016_key12_led_blue[mod]  = 0;
    uc_hek1016_key13_led_red[mod]   = 0;
    uc_hek1016_key13_led_green[mod] = 0;
    uc_hek1016_key13_led_blue[mod]  = 0;
    uc_hek1016_key14_led_red[mod]   = 0;
    uc_hek1016_key14_led_green[mod] = 0;
    uc_hek1016_key14_led_blue[mod]  = 0;
    uc_hek1016_key15_led_red[mod]   = 0;
    uc_hek1016_key15_led_green[mod] = 0;
    uc_hek1016_key15_led_blue[mod]  = 0;
    uc_hek1016_key16_led_red[mod]   = 0;
    uc_hek1016_key16_led_green[mod] = 0;
    uc_hek1016_key16_led_blue[mod]  = 0;
}

uint8_t hek1016_led_init(uint8_t mod)
{
    uint8_t tReturn = 0;
    if(mod >= HEK1016_MODULE_NUMBER) return tReturn;
    if(ul_tick_500us < TIME_OUT_1S)
    {
        uc_hek1016_key01_led_red[mod]   = 1;
        uc_hek1016_key01_led_green[mod] = 1;
        uc_hek1016_key01_led_blue[mod]  = 1;
        uc_hek1016_key02_led_red[mod]   = 1;
        uc_hek1016_key02_led_green[mod] = 1;
        uc_hek1016_key02_led_blue[mod]  = 1;
        uc_hek1016_key03_led_red[mod]   = 1;
        uc_hek1016_key03_led_green[mod] = 1;
        uc_hek1016_key03_led_blue[mod]  = 1;
        uc_hek1016_key04_led_red[mod]   = 1;
        uc_hek1016_key04_led_green[mod] = 1;
        uc_hek1016_key04_led_blue[mod]  = 1;
        uc_hek1016_key05_led_red[mod]   = 1;
        uc_hek1016_key05_led_green[mod] = 1;
        uc_hek1016_key05_led_blue[mod]  = 1;
        uc_hek1016_key06_led_red[mod]   = 1;
        uc_hek1016_key06_led_green[mod] = 1;
        uc_hek1016_key06_led_blue[mod]  = 1;
        uc_hek1016_key07_led_red[mod]   = 1;
        uc_hek1016_key07_led_green[mod] = 1;
        uc_hek1016_key07_led_blue[mod]  = 1;
        uc_hek1016_key08_led_red[mod]   = 1;
        uc_hek1016_key08_led_green[mod] = 1;
        uc_hek1016_key08_led_blue[mod]  = 1;
        uc_hek1016_key09_led_red[mod]   = 1;
        uc_hek1016_key09_led_green[mod] = 1;
        uc_hek1016_key09_led_blue[mod]  = 1;
        uc_hek1016_key10_led_red[mod]   = 1;
        uc_hek1016_key10_led_green[mod] = 1;
        uc_hek1016_key10_led_blue[mod]  = 1;
        uc_hek1016_key11_led_red[mod]   = 1;
        uc_hek1016_key11_led_green[mod] = 1;
        uc_hek1016_key11_led_blue[mod]  = 1;
        uc_hek1016_key12_led_red[mod]   = 1;
        uc_hek1016_key12_led_green[mod] = 1;
        uc_hek1016_key12_led_blue[mod]  = 1;
        uc_hek1016_key13_led_red[mod]   = 1;
        uc_hek1016_key13_led_green[mod] = 1;
        uc_hek1016_key13_led_blue[mod]  = 1;
        uc_hek1016_key14_led_red[mod]   = 1;
        uc_hek1016_key14_led_green[mod] = 1;
        uc_hek1016_key14_led_blue[mod]  = 1;
        uc_hek1016_key15_led_red[mod]   = 1;
        uc_hek1016_key15_led_green[mod] = 1;
        uc_hek1016_key15_led_blue[mod]  = 1;
        uc_hek1016_key16_led_red[mod]   = 1;
        uc_hek1016_key16_led_green[mod] = 1;
        uc_hek1016_key16_led_blue[mod]  = 1;
    }
    else
    {
        hek1016_led_clear(mod);
        tReturn = 1;
    }
    return tReturn;
}

void hek1016_can0_rx(CAN_DATA_FORMAT_T data,uint8_t mod)
{
    if(mod >= HEK1016_MODULE_NUMBER) return;
    if(data.id != ul_hek1016_rx_id[mod]) return;
    if((data.rx_len > 8) || (data.rx_len == 0)) return;

    uc_hek1016_key01[mod] = (data.rx_data[0]>>0)&0x03;
    uc_hek1016_key02[mod] = (data.rx_data[0]>>2)&0x03;
    uc_hek1016_key03[mod] = (data.rx_data[0]>>4)&0x03;
    uc_hek1016_key04[mod] = (data.rx_data[0]>>6)&0x03;
    uc_hek1016_key05[mod] = (data.rx_data[1]>>0)&0x03;
    uc_hek1016_key06[mod] = (data.rx_data[1]>>2)&0x03;
    uc_hek1016_key07[mod] = (data.rx_data[1]>>4)&0x03;
    uc_hek1016_key08[mod] = (data.rx_data[1]>>6)&0x03;
    uc_hek1016_key09[mod] = (data.rx_data[2]>>0)&0x03;
    uc_hek1016_key10[mod] = (data.rx_data[2]>>2)&0x03;
    uc_hek1016_key11[mod] = (data.rx_data[2]>>4)&0x03;
    uc_hek1016_key12[mod] = (data.rx_data[2]>>6)&0x03;
    uc_hek1016_key13[mod] = (data.rx_data[3]>>0)&0x03;
    uc_hek1016_key14[mod] = (data.rx_data[3]>>2)&0x03;
    uc_hek1016_key15[mod] = (data.rx_data[3]>>4)&0x03;
    uc_hek1016_key16[mod] = (data.rx_data[3]>>6)&0x03;
}
void hek1016_key_redefine(uint8_t mod)
{
    Lib_LockUnlockDataHandle(&uc_hek1016_key01_last[mod],&uc_hek1016_key01[mod],&uc_hek1016_key01_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key02_last[mod],&uc_hek1016_key02[mod],&uc_hek1016_key02_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key03_last[mod],&uc_hek1016_key03[mod],&uc_hek1016_key03_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key04_last[mod],&uc_hek1016_key04[mod],&uc_hek1016_key04_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key05_last[mod],&uc_hek1016_key05[mod],&uc_hek1016_key05_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key06_last[mod],&uc_hek1016_key06[mod],&uc_hek1016_key06_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key07_last[mod],&uc_hek1016_key07[mod],&uc_hek1016_key07_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key08_last[mod],&uc_hek1016_key08[mod],&uc_hek1016_key08_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key09_last[mod],&uc_hek1016_key09[mod],&uc_hek1016_key09_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key10_last[mod],&uc_hek1016_key10[mod],&uc_hek1016_key10_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key11_last[mod],&uc_hek1016_key11[mod],&uc_hek1016_key11_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key12_last[mod],&uc_hek1016_key12[mod],&uc_hek1016_key12_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key13_last[mod],&uc_hek1016_key13[mod],&uc_hek1016_key13_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key14_last[mod],&uc_hek1016_key14[mod],&uc_hek1016_key14_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key15_last[mod],&uc_hek1016_key15[mod],&uc_hek1016_key15_cmd[mod],SelfLock);
    Lib_LockUnlockDataHandle(&uc_hek1016_key16_last[mod],&uc_hek1016_key16[mod],&uc_hek1016_key16_cmd[mod],SelfLock);
}
uint32_t ul_hek1016_key_cnt[HEK1016_MODULE_NUMBER]   = { 0 };
uint8_t uc_key01_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key02_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key03_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key04_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key05_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key06_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key07_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key08_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key09_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key10_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key11_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key12_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key13_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key14_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key15_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };
uint8_t uc_key16_led_ctrl_cnt[HEK1016_MODULE_NUMBER] = { 0 };

void hek1016_led_ctrl(uint8_t mod)
{
    if(mod >= HEK1016_MODULE_NUMBER) return;
    /*key0*/
    if(uc_hek1016_key01_cmd[mod] == 1)
    {
        uc_hek1016_key01_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key01_led_ctrl_cnt[mod]++;
        if(uc_key01_led_ctrl_cnt[mod] > 3) uc_key01_led_ctrl_cnt[mod] = 0;
    }
    if(uc_key01_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key01_led_red[mod]   = 1;
        uc_hek1016_key01_led_green[mod] = 0;
        uc_hek1016_key01_led_blue[mod]  = 0;
    }
    else if(uc_key01_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key01_led_red[mod]   = 0;
        uc_hek1016_key01_led_green[mod] = 1;
        uc_hek1016_key01_led_blue[mod]  = 0; 
    }
    else if(uc_key01_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key01_led_red[mod]   = 0;
        uc_hek1016_key01_led_green[mod] = 0;
        uc_hek1016_key01_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key01_led_red[mod]   = 0;
        uc_hek1016_key01_led_green[mod] = 0;
        uc_hek1016_key01_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key02_cmd[mod] == 1)
    {
        uc_hek1016_key02_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key02_led_ctrl_cnt[mod]++;
        if(uc_key02_led_ctrl_cnt[mod] > 3) uc_key02_led_ctrl_cnt[mod] = 0;
    }
    if(uc_key02_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key02_led_red[mod]   = 1;
        uc_hek1016_key02_led_green[mod] = 0;
        uc_hek1016_key02_led_blue[mod]  = 0;
    }
    else if(uc_key02_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key02_led_red[mod]   = 0;
        uc_hek1016_key02_led_green[mod] = 1;
        uc_hek1016_key02_led_blue[mod]  = 0; 
    }
    else if(uc_key02_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key02_led_red[mod]   = 0;
        uc_hek1016_key02_led_green[mod] = 0;
        uc_hek1016_key02_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key02_led_red[mod]   = 0;
        uc_hek1016_key02_led_green[mod] = 0;
        uc_hek1016_key02_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key03_cmd[mod] == 1)
    {
        uc_hek1016_key03_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key03_led_ctrl_cnt[mod]++;
        if(uc_key03_led_ctrl_cnt[mod] > 3) uc_key03_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key03_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key03_led_red[mod]   = 1;
        uc_hek1016_key03_led_green[mod] = 0;
        uc_hek1016_key03_led_blue[mod]  = 0; 
    }
    else if(uc_key03_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key03_led_red[mod]   = 0;
        uc_hek1016_key03_led_green[mod] = 1;
        uc_hek1016_key03_led_blue[mod]  = 0; 
    }
    else if(uc_key03_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key03_led_red[mod]   = 0;
        uc_hek1016_key03_led_green[mod] = 0;
        uc_hek1016_key03_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key03_led_red[mod]   = 0;
        uc_hek1016_key03_led_green[mod] = 0;
        uc_hek1016_key03_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key04_cmd[mod] == 1)
    {
        uc_hek1016_key04_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key04_led_ctrl_cnt[mod]++;
        if(uc_key04_led_ctrl_cnt[mod] > 3) uc_key04_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key04_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key04_led_red[mod]   = 1;
        uc_hek1016_key04_led_green[mod] = 0;
        uc_hek1016_key04_led_blue[mod]  = 0; 
    }
    else if(uc_key04_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key04_led_red[mod]   = 0;
        uc_hek1016_key04_led_green[mod] = 1;
        uc_hek1016_key04_led_blue[mod]  = 0; 
    }
    else if(uc_key04_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key04_led_red[mod]   = 0;
        uc_hek1016_key04_led_green[mod] = 0;
        uc_hek1016_key04_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key04_led_red[mod]   = 0;
        uc_hek1016_key04_led_green[mod] = 0;
        uc_hek1016_key04_led_blue[mod]  = 0;
    }
    if(uc_hek1016_key05_cmd[mod] == 1)
    {
        uc_hek1016_key05_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key05_led_ctrl_cnt[mod]++;
        if(uc_key05_led_ctrl_cnt[mod] > 3) uc_key05_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key05_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key05_led_red[mod]   = 1;
        uc_hek1016_key05_led_green[mod] = 0;
        uc_hek1016_key05_led_blue[mod]  = 0; 
    }
    else if(uc_key05_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key05_led_red[mod]   = 0;
        uc_hek1016_key05_led_green[mod] = 1;
        uc_hek1016_key05_led_blue[mod]  = 0; 
    }
    else if(uc_key05_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key05_led_red[mod]   = 0;
        uc_hek1016_key05_led_green[mod] = 0;
        uc_hek1016_key05_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key05_led_red[mod]   = 0;
        uc_hek1016_key05_led_green[mod] = 0;
        uc_hek1016_key05_led_blue[mod]  = 0;
    }
    if(uc_hek1016_key06_cmd[mod] == 1)
    {
        uc_hek1016_key06_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key06_led_ctrl_cnt[mod]++;
        if(uc_key06_led_ctrl_cnt[mod] > 3) uc_key06_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key06_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key06_led_red[mod]   = 1;
        uc_hek1016_key06_led_green[mod] = 0;
        uc_hek1016_key06_led_blue[mod]  = 0; 
    }
    else if(uc_key06_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key06_led_red[mod]   = 0;
        uc_hek1016_key06_led_green[mod] = 1;
        uc_hek1016_key06_led_blue[mod]  = 0; 
    }
    else if(uc_key06_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key06_led_red[mod]   = 0;
        uc_hek1016_key06_led_green[mod] = 0;
        uc_hek1016_key06_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key06_led_red[mod]   = 0;
        uc_hek1016_key06_led_green[mod] = 0;
        uc_hek1016_key06_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key07_cmd[mod] == 1)
    {
        uc_hek1016_key07_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key07_led_ctrl_cnt[mod]++;
        if(uc_key07_led_ctrl_cnt[mod] > 3) uc_key07_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key07_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key07_led_red[mod]   = 1;
        uc_hek1016_key07_led_green[mod] = 0;
        uc_hek1016_key07_led_blue[mod]  = 0; 
    }
    else if(uc_key07_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key07_led_red[mod]   = 0;
        uc_hek1016_key07_led_green[mod] = 1;
        uc_hek1016_key07_led_blue[mod]  = 0; 
    }
    else if(uc_key07_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key07_led_red[mod]   = 0;
        uc_hek1016_key07_led_green[mod] = 0;
        uc_hek1016_key07_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key07_led_red[mod]   = 0;
        uc_hek1016_key07_led_green[mod] = 0;
        uc_hek1016_key07_led_blue[mod]  = 0;
    }
    if(uc_hek1016_key08_cmd[mod] == 1)
    {
        uc_hek1016_key08_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key08_led_ctrl_cnt[mod]++;
        if(uc_key08_led_ctrl_cnt[mod] > 3) uc_key08_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key08_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key08_led_red[mod]   = 1;
        uc_hek1016_key08_led_green[mod] = 0;
        uc_hek1016_key08_led_blue[mod]  = 0; 
    }
    else if(uc_key08_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key08_led_red[mod]   = 0;
        uc_hek1016_key08_led_green[mod] = 1;
        uc_hek1016_key08_led_blue[mod]  = 0; 
    }
    else if(uc_key08_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key08_led_red[mod]   = 0;
        uc_hek1016_key08_led_green[mod] = 0;
        uc_hek1016_key08_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key08_led_red[mod]   = 0;
        uc_hek1016_key08_led_green[mod] = 0;
        uc_hek1016_key08_led_blue[mod]  = 0; 
    }

    if(uc_hek1016_key09_cmd[mod] == 1)
    {
        uc_hek1016_key09_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key09_led_ctrl_cnt[mod]++;
        if(uc_key09_led_ctrl_cnt[mod] > 3) uc_key09_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key09_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key09_led_red[mod]   = 1;
        uc_hek1016_key09_led_green[mod] = 0;
        uc_hek1016_key09_led_blue[mod]  = 0; 
    }
    else if(uc_key09_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key09_led_red[mod]   = 0;
        uc_hek1016_key09_led_green[mod] = 1;
        uc_hek1016_key09_led_blue[mod]  = 0; 
    }
    else if(uc_key09_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key09_led_red[mod]   = 0;
        uc_hek1016_key09_led_green[mod] = 0;
        uc_hek1016_key09_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key09_led_red[mod]   = 0;
        uc_hek1016_key09_led_green[mod] = 0;
        uc_hek1016_key09_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key10_cmd[mod] == 1)
    {
        uc_hek1016_key10_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key10_led_ctrl_cnt[mod]++;
        if(uc_key10_led_ctrl_cnt[mod] > 3) uc_key10_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key10_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key10_led_red[mod]   = 1;
        uc_hek1016_key10_led_green[mod] = 0;
        uc_hek1016_key10_led_blue[mod]  = 0; 
    }
    else if(uc_key10_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key10_led_red[mod]   = 0;
        uc_hek1016_key10_led_green[mod] = 1;
        uc_hek1016_key10_led_blue[mod]  = 0; 
    }
    else if(uc_key10_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key10_led_red[mod]   = 0;
        uc_hek1016_key10_led_green[mod] = 0;
        uc_hek1016_key10_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key10_led_red[mod]   = 0;
        uc_hek1016_key10_led_green[mod] = 0;
        uc_hek1016_key10_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key11_cmd[mod] == 1)
    {
        uc_hek1016_key11_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key11_led_ctrl_cnt[mod]++;
        if(uc_key11_led_ctrl_cnt[mod] > 3) uc_key11_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key11_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key11_led_red[mod]   = 1;
        uc_hek1016_key11_led_green[mod] = 0;
        uc_hek1016_key11_led_blue[mod]  = 0; 
    }
    else if(uc_key11_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key11_led_red[mod]   = 0;
        uc_hek1016_key11_led_green[mod] = 1;
        uc_hek1016_key11_led_blue[mod]  = 0; 
    }
    else if(uc_key11_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key11_led_red[mod]   = 0;
        uc_hek1016_key11_led_green[mod] = 0; 
        uc_hek1016_key11_led_blue[mod]  = 1;
    }
    else
    {
        uc_hek1016_key11_led_red[mod]   = 0;
        uc_hek1016_key11_led_green[mod] = 0;
        uc_hek1016_key11_led_blue[mod]  = 0;
    }
    if(uc_hek1016_key12_cmd[mod] == 1)
    {
        uc_hek1016_key12_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key12_led_ctrl_cnt[mod]++;
        if(uc_key12_led_ctrl_cnt[mod] > 3) uc_key12_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key12_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key12_led_red[mod]   = 1;
        uc_hek1016_key12_led_green[mod] = 0;
        uc_hek1016_key12_led_blue[mod]  = 0; 
    }
    else if(uc_key12_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key12_led_red[mod]   = 0;
        uc_hek1016_key12_led_green[mod] = 1;
        uc_hek1016_key12_led_blue[mod]  = 0; 
    }
    else if(uc_key12_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key12_led_red[mod]   = 0;
        uc_hek1016_key12_led_green[mod] = 0;
        uc_hek1016_key12_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key12_led_red[mod]   = 0;
        uc_hek1016_key12_led_green[mod] = 0;
        uc_hek1016_key12_led_blue[mod]  = 0;  
    }
    if(uc_hek1016_key13_cmd[mod] == 1)
    {
        uc_hek1016_key13_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key13_led_ctrl_cnt[mod]++;
        if(uc_key13_led_ctrl_cnt[mod] > 3) uc_key13_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key13_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key13_led_red[mod]   = 1;
        uc_hek1016_key13_led_green[mod] = 0;
        uc_hek1016_key13_led_blue[mod]  = 0; 
    }
    else if(uc_key13_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key13_led_red[mod]   = 0;
        uc_hek1016_key13_led_green[mod] = 1;
        uc_hek1016_key13_led_blue[mod]  = 0; 
    }
    else if(uc_key13_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key13_led_red[mod]   = 0;
        uc_hek1016_key13_led_green[mod] = 0;
        uc_hek1016_key13_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key13_led_red[mod]   = 0;
        uc_hek1016_key13_led_green[mod] = 0;
        uc_hek1016_key13_led_blue[mod]  = 0; 
    }
    if(uc_hek1016_key14_cmd[mod] == 1)
    {
        uc_hek1016_key14_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key14_led_ctrl_cnt[mod]++;
        if(uc_key14_led_ctrl_cnt[mod] > 3) uc_key14_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key14_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key14_led_red[mod]   = 1;
        uc_hek1016_key14_led_green[mod] = 0;
        uc_hek1016_key14_led_blue[mod]  = 0; 
    }
    else if(uc_key14_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key14_led_red[mod]   = 0;
        uc_hek1016_key14_led_green[mod] = 1;
        uc_hek1016_key14_led_blue[mod]  = 0; 
    }
    else if(uc_key14_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key14_led_red[mod]   = 0;
        uc_hek1016_key14_led_green[mod] = 0;
        uc_hek1016_key14_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key14_led_red[mod]   = 0;
        uc_hek1016_key14_led_green[mod] = 0;
        uc_hek1016_key14_led_blue[mod]  = 0;
    }
    if(uc_hek1016_key15_cmd[mod] == 1)
    {
        uc_hek1016_key15_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key15_led_ctrl_cnt[mod]++;
        if(uc_key15_led_ctrl_cnt[mod] > 3) uc_key15_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key15_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key15_led_red[mod]   = 1;
        uc_hek1016_key15_led_green[mod] = 0;
        uc_hek1016_key15_led_blue[mod]  = 0; 
    }
    else if(uc_key15_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key15_led_red[mod]   = 0;
        uc_hek1016_key15_led_green[mod] = 1;
        uc_hek1016_key15_led_blue[mod]  = 0; 
    }
    else if(uc_key15_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key15_led_red[mod]   = 0;
        uc_hek1016_key15_led_green[mod] = 0;
        uc_hek1016_key15_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key15_led_red[mod]   = 0;
        uc_hek1016_key15_led_green[mod] = 0;
        uc_hek1016_key15_led_blue[mod]  = 0; 
    }
    if(uc_hek1016_key16_cmd[mod] == 1)
    {
        uc_hek1016_key16_cmd[mod] = 0;
        ul_hek1016_key_cnt[mod]++;
        uc_key16_led_ctrl_cnt[mod]++;
        if(uc_key16_led_ctrl_cnt[mod] > 3) uc_key16_led_ctrl_cnt[mod] = 0; 
    }
    if(uc_key16_led_ctrl_cnt[mod] == 1)
    {
        uc_hek1016_key16_led_red[mod]   = 1;
        uc_hek1016_key16_led_green[mod] = 0;
        uc_hek1016_key16_led_blue[mod]  = 0; 
    }
    else if(uc_key16_led_ctrl_cnt[mod] == 2)
    {
        uc_hek1016_key16_led_red[mod]   = 0;
        uc_hek1016_key16_led_green[mod] = 1;
        uc_hek1016_key16_led_blue[mod]  = 0; 
    }
    else if(uc_key16_led_ctrl_cnt[mod] == 3)
    {
        uc_hek1016_key16_led_red[mod]   = 0;
        uc_hek1016_key16_led_green[mod] = 0;
        uc_hek1016_key16_led_blue[mod]  = 1; 
    }
    else
    {
        uc_hek1016_key16_led_red[mod]   = 0;
        uc_hek1016_key16_led_green[mod] = 0;
        uc_hek1016_key16_led_blue[mod]  = 0;
    }
}
void hek1016_can0_tx(uint8_t mod)
{
    uint8_t buf[8] = { 0 };

    buf[0] = (uc_hek1016_key01_led_red[mod]  <<0) | (uc_hek1016_key02_led_red[mod]  <<1) | (uc_hek1016_key03_led_red[mod]  <<2) | (uc_hek1016_key04_led_red[mod]  <<3) |
             (uc_hek1016_key05_led_red[mod]  <<4) | (uc_hek1016_key06_led_red[mod]  <<5) | (uc_hek1016_key07_led_red[mod]  <<6) | (uc_hek1016_key08_led_red[mod]  <<7);
    buf[1] = (uc_hek1016_key01_led_green[mod]<<0) | (uc_hek1016_key02_led_green[mod]<<1) | (uc_hek1016_key03_led_green[mod]<<2) | (uc_hek1016_key04_led_green[mod]<<3) |
             (uc_hek1016_key05_led_green[mod]<<4) | (uc_hek1016_key06_led_green[mod]<<5) | (uc_hek1016_key07_led_green[mod]<<6) | (uc_hek1016_key08_led_green[mod]<<7);
    buf[2] = (uc_hek1016_key01_led_blue[mod] <<0) | (uc_hek1016_key02_led_blue[mod] <<1) | (uc_hek1016_key03_led_blue[mod] <<2) | (uc_hek1016_key04_led_blue[mod] <<3) |
             (uc_hek1016_key05_led_blue[mod] <<4) | (uc_hek1016_key06_led_blue[mod] <<5) | (uc_hek1016_key07_led_blue[mod] <<6) | (uc_hek1016_key08_led_blue[mod] <<7);
    buf[7] = uc_hek1016_backlight[mod];
    Can0_Data_Store_Fifo(ul_hek1016_tx_id_first[mod],buf,8);

    buf[0] = (uc_hek1016_key09_led_red[mod]  <<0) | (uc_hek1016_key10_led_red[mod]  <<1) | (uc_hek1016_key11_led_red[mod]  <<2) | (uc_hek1016_key12_led_red[mod]  <<3) |
             (uc_hek1016_key13_led_red[mod]  <<4) | (uc_hek1016_key14_led_red[mod]  <<5) | (uc_hek1016_key15_led_red[mod]  <<6) | (uc_hek1016_key16_led_red[mod]  <<7);
    buf[1] = (uc_hek1016_key09_led_green[mod]<<0) | (uc_hek1016_key10_led_green[mod]<<1) | (uc_hek1016_key11_led_green[mod]<<2) | (uc_hek1016_key12_led_green[mod]<<3) |
             (uc_hek1016_key13_led_green[mod]<<4) | (uc_hek1016_key14_led_green[mod]<<5) | (uc_hek1016_key15_led_green[mod]<<6) | (uc_hek1016_key16_led_green[mod]<<7);
    buf[2] = (uc_hek1016_key09_led_blue[mod] <<0) | (uc_hek1016_key10_led_blue[mod] <<1) | (uc_hek1016_key11_led_blue[mod] <<2) | (uc_hek1016_key12_led_blue[mod] <<3) |
             (uc_hek1016_key13_led_blue[mod] <<4) | (uc_hek1016_key14_led_blue[mod] <<5) | (uc_hek1016_key15_led_blue[mod] <<6) | (uc_hek1016_key16_led_blue[mod] <<7);
    Can0_Data_Store_Fifo(ul_hek1016_tx_id_second[mod],buf,8);
}
uint8_t uc_hek1016_test_status[HEK1016_MODULE_NUMBER] = { 0 };
void hek1016_test(uint8_t mod)
{
    uint8_t temp = 0;
    switch(uc_hek1016_test_status[mod])
    {
        case 0:
            temp = hek1016_led_init(mod);
            if(temp == 1) uc_hek1016_test_status[mod] += 1;
            break;
        case 1:
            hek1016_key_redefine(mod);
            hek1016_led_ctrl(mod);
            break;
        default:
        break;
    }
}
void hek1016_run(void)
{
    hek1016_test(0);
    hek1016_test(1);
    hek1016_test(2);
    hek1016_test(3);

    hek1016_can0_tx(0);
    hek1016_can0_tx(1);
    hek1016_can0_tx(2);
    hek1016_can0_tx(3);
}









